//
//  collecTionCtroller.m
//  时尚男士
//
//  Created by 张家为 on 15/6/10.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "collecTionCtroller.h"
#import "MainDetailedPageViewController.h"
@interface collecTionCtroller ()<UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
@property (nonatomic, retain)NSMutableArray *arrr;
@property (nonatomic, retain)NSMutableArray *collectTitleArr;

@end

@implementation collecTionCtroller
-(void)dealloc{
    [_arrr release];
    [_collectTitleArr release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.jpg"]];
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    NSString *myPath = [docPath stringByAppendingPathComponent:[NSString stringWithFormat:@"title.plist"]];
    NSString *myPath1 = [docPath stringByAppendingPathComponent:[NSString stringWithFormat:@"collect.plist"]];
    self.collectTitleArr = [NSMutableArray arrayWithContentsOfFile:myPath];
    self.arrr = [NSMutableArray arrayWithContentsOfFile:myPath1];
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, (self.collectTitleArr.count)* 44) style: UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];

   // Do any additional setup after loading the view.

}
- (void)changeColor :(NSNotification *)noti{
   }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (self.collectTitleArr.count == 0) {
        UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"暂无任何收藏" message:nil delegate:self cancelButtonTitle:@"确认" otherButtonTitles:@"取消", nil];
        alter.delegate = self;
        [alter show];
    }
    return self.collectTitleArr.count;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    [self.navigationController popViewControllerAnimated:NO];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:    UITableViewCellStyleValue1 reuseIdentifier:@"reuse"];
    }
    cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"xbg.png"]];
    cell.textLabel.text = [self.collectTitleArr objectAtIndex:indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    MainDetailedPageViewController *mv = [[MainDetailedPageViewController alloc]init];
    [self.navigationController pushViewController:mv animated:YES];
    mv.myIdStr =[self.arrr objectAtIndex:indexPath.row];
    [mv release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
